package com.ruoyi.web.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.domain.dto.MonitorAreaDto;
import com.ruoyi.web.domain.vo.MonitorAreaVo;
import com.ruoyi.web.service.IMonitorAreaService;
import com.ruoyi.web.service.IMonitorCameraService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "监控摄像头控制层")
@RequestMapping("/monitorCamera")
public class MonitorCameraController extends BaseController {

    @Autowired
    private IMonitorCameraService monitorCameraService;
    @Autowired
    private IMonitorAreaService monitorAreaService;

    @PostMapping
    @ApiOperation("新增监控摄像头")
    public AjaxResult add(@RequestBody MonitorAreaDto dto) {
        return monitorCameraService.add(dto);
    }

    @GetMapping("/list")
    @ApiOperation("查询监控摄像头列表")
    public TableDataInfo getList(MonitorAreaDto dto) {
        startPage();
        List<MonitorAreaVo> list = monitorAreaService.getList(dto);
        return getDataTable(list);
    }

    @GetMapping("/{baseId}")
    @ApiOperation("查询监控摄像头详情")
    public AjaxResult getDetails(@PathVariable("baseId") Long baseId) {
        return AjaxResult.success(monitorAreaService.getDetails(baseId));
    }

    @PutMapping
    @ApiOperation("编辑监控摄像头")
    public AjaxResult update(@RequestBody MonitorAreaDto dto) {
        return monitorCameraService.update(dto);
    }

    @DeleteMapping
    @ApiOperation("删除监控摄像头")
    public AjaxResult delete(MonitorAreaDto dto) {
        return monitorCameraService.delete(dto);
    }

    @GetMapping("/cameraCount")
    @ApiOperation("查询所有监控点数据统计")
    public AjaxResult getAllCamerasCount() {
        return AjaxResult.success(monitorAreaService.getAllCamerasCount());
    }
}
